package com.github.fujianlian.klinechart;


import com.github.fujianlian.klinechart.utils.BigDecimalUtils;

import java.util.Date;

public class Kline {

    private Date date;
    private long timestample;
    private String dateStr;
    private double open;
    private double close;
    private double high;
    private double low;
    private double persent;
    private double volume;

    public Kline(Date date, double open, double close, double high, double low) {
        this.date = date;
        this.timestample =date.getTime();
        try {
            this.open = BigDecimalUtils.round(open, 3);
        } catch (IllegalAccessException e) {
            this.open = open;
        }
        try {
            this.close = BigDecimalUtils.round(close, 3);
        } catch (IllegalAccessException e) {
            this.close = close;
        }
        try {
            this.high = BigDecimalUtils.round(high, 3);
        } catch (IllegalAccessException e) {
            this.high = high;
        }
        try {
            this.low = BigDecimalUtils.round(low, 3);
        } catch (IllegalAccessException e) {
            this.low = low;
        }
    }

    public long getTimestample() {
        return timestample;
    }

    public void setTimestample(long timestample) {
        this.timestample = timestample;
    }

    public double getVolume() {
        return volume;
    }

    public void setVolume(double volume) {
        this.volume = volume;
    }

    public Date getDate() {
        return date;
    }

    public String getDateStr() {
        return dateStr;
    }

    public double getOpen() {
        return open;
    }

    public double getClose() {
        return close;
    }

    public double getHigh() {
        return high;
    }

    public void setDate(Date date) {
        this.date = date;
    }

    public void setDateStr(String dateStr) {
        this.dateStr = dateStr;
    }

    public void setOpen(double open) {
        this.open = open;
    }

    public void setClose(double close) {
        this.close = close;
    }

    public void setHigh(double high) {
        this.high = high;
    }

    public void setLow(double low) {
        this.low = low;
    }

    public double getPersent() {
        return persent;
    }

    public void setPersent(double persent) {
        this.persent = persent;
    }

    public double getLow() {
        return low;
    }

    @Override
    public String toString() {
        return "Kline{" + (
                date == null ? "" : "date=" + date.toLocaleString()) +
                ", dateStr='" + dateStr + '\'' +
                ", open=" + open +
                ", close=" + close +
                ", high=" + high +
                ", low=" + low +
                ", persent=" + (persent * 100) + "%" +
                ", volume=" + volume +
                '}';
    }
}
